﻿
using System.Xml;
using HuaXingSDK.Response;

namespace HuaXingSDK.Request
{
    public class Req单笔发标 : HXSyncRequest<Res单笔发标>
    {
        public string MerchantName { get; }
        public string LoanNo { get; set; }
        public string InvestId { get; set; }
        public string InvestObjName { get; set; }
        public string InvestObjInfo { get; set; }
        public decimal? MinInvestAMT { get; set; }
        public decimal? MaxInvestAMT { get; set; }
        public decimal InvestObjAMT { get; set; }
        public int InvestBeginDate { get; set; }
        public int InvestEndDate { get; set; }
        public int? RepayDate { get; set; }
        public decimal YearRate { get; set; }
        public int InvestRange { get; set; }
        public string RateStyle { get; set; }
        public string RepayStyle { get; set; }
        public Req单笔发标InvestObjState InvestObjState { get; set; }
        public int BWTotalNum { get; set; }
        public string Remark { get; set; }
        public bool? ZRFlag { get; set; }
        public string REFLoanNo { get; set; }
        public string OldReqseq { get; set; }
        public string EXT_FILED1 { get; set; }
        public BWItem BWList { get; set; }

        public Req单笔发标() : base(HXTransCode.Req_单笔发标)
        {
            MerchantName = HXConfigs.商户名称;
            SetNodeOrderAfter(nameof(MerchantId), nameof(MerchantName));
        }

        protected override void OnNode(XmlNode parentNode, string name, object value)
        {
            if (value is Req单笔发标InvestObjState)
            {
                value = (int) value;
            }
            base.OnNode(parentNode, name, value);
        }

        public class BWItem : EntityToXml
        {
            public string BWACName { get; set; }
            public HXIDType BWIDType { get; set; }
            public string BWIDNo { get; set; }
            public string BWACNo { get; set; }
            public string BWACBankId { get; set; }
            public string BWACBankName { get; set; }
            public decimal BWAMT { get; set; }
            public string MortgageId { get; set; }
            public string MortgageInfo { get; set; }
            public int? CheckDate { get; set; }
            public string Remark { get; set; }
            public string EXT_FILED2 { get; set; }
            public string EXT_FILED3 { get; set; }

            protected override void OnNode(XmlNode parentNode, string name, object value)
            {
                if (value is HXIDType)
                {
                    value = "1010";
                }
                base.OnNode(parentNode, name, value);
            }
        }

        public enum Req单笔发标InvestObjState
        {
            正常 = 0,
            撤销 = 1
        }
    }
}
